package com.cskaoyan.bean;

import com.github.pagehelper.PageInfo;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * 类<code>Doc</code>用于：TODO
 *
 * @author Acher
 * @version 1.0
 * @date 2021-10-18
 */
@NoArgsConstructor
@Data
public class PageDataVo<T> {
    private Integer total;
    private Integer pages;
    private Integer limit;
    private Integer page;
    private List<T> list;

    public static <T>PageDataVo ok(List<T> list) {
        PageInfo<T> pageInfo = new PageInfo<>(list);
        PageDataVo<T> pageData = new PageDataVo<>();
        pageData.setPage(pageInfo.getPageNum());
        pageData.setLimit(pageInfo.getPageSize());
        pageData.setPages(pageInfo.getPages());
        pageData.setTotal((int) pageInfo.getTotal());
        pageData.setList(list);
        return pageData;
    }
}
